﻿var eff = "#fEffect/CharacterEff/1051296/1/0#";
/*
*	冰火家族萬能NPC
*
*
*
*
*
*/
var x = "#fEffect/CharacterEff/1112949/0/0#";//高音譜記號
var kk = "#fEffect/BasicEff/MainNotice/Boss/Default/0#";//BOSS
var c = "#fEffect/CharacterEff/1032063/0/0#";//"#fUI/UIMiniGame/starPlanetRPS/heart#";//愛心
var cmark = "#fUI/UIPVP/ChampionMark/1#";//愛心
var lb = "#fEffect/ItemEff/1112811/0/0#";//藍色小光
var b = "#fEffect/CharacterEff/Shaman/1#";//超萌熊熊
var cat = "#fEffect/CharacterEff/Shaman/4#";//超萌喵咪
var leaf = "#fUI/Basic.img/Cursor/18/0#";
var status;
var sele1;
var pass;


function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {

    if (mode == 0) {
	cm.dispose();
	return;
    } else if (mode == 1){
	status++;
    } else {
	status--;
    }

    switch (status) {
        case 0: 
			text = "\t  "+c+"#fn华文行楷##fs30##e#k #b我的帳號 " +c+ "\r\n#n#fs12##fn宋体#";
			
			var map = Java.type("client.MapleClient");
			text += "#L0#" + eff + "\t遊戲帳號： #r" + format(" ", 15, cm.getClient().getAccountName()) + "#b #e#r【改密】#b#n#l\r\n";
			text += "#L1#" + eff + "\t贊助點數： #r" + format(" ", 15, cm.getRMB().toString()) + "#b #e#r【贊助】#n#l\r\n";
			text += "#L2#" + eff + "\t#b累積贊助： #r" + format(" ", 15, cm.getTotalRMB().toString()) + "#b #e#r【禮包】#b#n#l\r\n";
			text += "#L3#" + eff + "\t剩餘點券： #r" + format(" ", 15, cm.getPlayer().getCSPoints(1).toString()) + "#b #e#r【兌換】#b#n#l\r\n";
			text += "\r\n\r\n\t\t   #L999#" + leaf +"#fn华文行楷##fs22##e#r回上一頁#l"
			text += "\r\n\r\n  " +c+c+c+c+c+c;
			cm.sendSimple(text);
            break;
        case 1: 
			sele1 = selection;
			switch (selection){
				case 0://帳號
					text = "#d目前將要更改的密碼為 #r安全碼#d 並非 #r登入密碼#k!\r\n安全碼在#r刪除整欄道具時將可使用!\r\n#r請輸入原本的#r安全碼#k(預設:#r0000#k)";
					cm.sendGetText(text);
					break;
				case 1://贊助
					text = "#h #您好，有什麼能為您服務的嗎?#b\r\n\r\n#L0#我要贊助#l\r\n#L1#我已繳費要領取贊助點#l"
					cm.sendSimple(text);
					break;
				case 2://禮包
					cm.dispose();
					cm.openNpc(1052253, "paylog");
					break;
				case 3://兌換
					cm.dispose();
					cm.openNpc(9300011,1);
					break;
				case 999://回上一頁
					cm.dispose();
					cm.openNpc(1052253, 0);
					break;
			}
            break;
		case 2:
			switch(sele1){
				case 0:
					var ori = cm.getClient().getAccInfoFromDB().get("safecode");
					if(ori == cm.getText()){
						text = "#r請輸入要改的#r安全碼#k";
						cm.sendGetText(text);
					} else {
						cm.sendOk("安全碼輸入錯誤，請重新輸入。")
						cm.dispose();
						return;
					}
					break;
				case 1:
					if(selection == 0){
						cm.dispose();
						cm.openNpc(1052253,"getDonatePage");
					}else{
						cm.dispose();
						cm.openNpc(1052253,"getDonate");
					}
					return;
				default:
					cm.sendOk("發生錯誤，請聯繫管理員!");
					cm.dispose();
					return;
			}
			break;
		case 3:
			switch(sele1){
				case 0:
					pass = cm.getText();
					text = "#r請再次輸入要改的#r安全碼#k";
					cm.sendGetText(text);
					break;
			}
			break;
		case 4:
			switch(sele1){
				case 0:
					var r_pass = cm.getText();
					if(r_pass.match(/\d/) && r_pass.match(/[a-z]/i) && !r_pass.match(/[^a-z0-9]/)){
						if(pass == r_pass){
							cm.setSafeCode(r_pass);
							cm.sendOk("安全碼更改成功!");
							cm.dispose();
							return;
						} else {
							cm.sendOk("第二次安全碼輸入與第一次不相符，請重新輸入。")
							cm.dispose();
							return;
						}
					}else{
						cm.sendOk("非法字元,僅接受英文或數字,且至少要1個英文1個數字!");
						cm.dispose();
						return;
					}
					break;
			}
			break;
        default:
			cm.sendOk("發生錯誤，請聯繫管理員!");
			cm.dispose();
			break;
    }
}
/*

var ttt = "#fUI/UIWindow/Quest/icon2/7#";//"+ttt+"//美化1

var status = -1;

function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == 0) {
        cm.dispose();
        return;
    } else {
        status++;
    }
    if (status == 0) {
        var map = Java.type("client.MapleClient");
        var text = "#d当前账户信息如下：\r\n";
        text += "====================================\r\n#b"
        text += "#L0#" + eff + "\t游戏账号： #r" + format(" ", 15, cm.getClient().getAccountName()) + "#b #e#r【改密】#b#n#l\r\n";
        text += "#L1#" + eff + "\t贊助點余额： #r" + format(" ", 15, cm.getRMB().toString()) + "#b #e#r【充值】#n#l\r\n";
        text += "#L2#" + eff + "\t#b累计充值： #r" + format(" ", 15, cm.getTotalRMB().toString()) + "#b #e#r【礼包】#b#n#l\r\n";
        text += "#L3#" + eff + "\t剩余点券： #r" + format(" ", 15, cm.getPlayer().getCSPoints(1).toString()) + "#b #e#r【兑换】#b#n#l\r\n";
        text += "#L4#" + eff + "\t剩余抵用： #r" + format(" ", 15, cm.getPlayer().getCSPoints(2).toString()) + "#b #e#r【兑换】#b#n#l\r\n\r\n";
        text += "\t\t\t\t#L5#"+ "#b" + ttt + "返回上一页";
        cm.sendSimple(text);
    } else if (status == 1) {
        if (selection == 0) {
            cm.sendOk("暂时不支持在线改密，請前往登陆器改密。");
            cm.dispose();
        } else if (selection == 1) {
            cm.openWeb("http://www.caihongms.com");
            cm.dispose();
        } else if (selection == 2) { // 礼包
            cm.dispose();
            cm.openNpc(1530638, 2);
        } else if (selection == 3) {
            selection = 0;
            cm.dispose();
            cm.openNpc(9300011, 2);
        } else if (selection == 4) {
            cm.sendOk("暂时不支持抵用券换点券。");
            cm.dispose();
		 } else if (selection == 5) {
			cm.dispose();
            cm.openNpc(1530635, 0);
        }
    }
}
*/

var format = function FormatString(c, length, content) {
    var str = "";
    var cs = "";
    if (content.length > length) {
        str = content;
    } else {
        for (var j = 0; j < length - content.getBytes("GB2312").length; j++) {
            cs = cs + c;
        }
    }
    str = content + cs;
    return str;
}
    